
<html>
<head>
<#include "/common/common2.ftl"/>
</head>
<body>
	<div class="row" id="rrapp" v-cloak>
		<div class="col-xs-12">
			<div class="m-b-md">
				<div class="layui-form-layui-form-pane" role="form" id="searchForm" name="searchForm">
					<a href="javascript:void(0)" @click="updatePassword" class="layui-btn layui-btn-warm" id="search">修改密码</a>
				</div>
			</div>
		</div>
		<div class="col-xs-12">
			<div class="box">
				<div class="box-header">
					<h3 class="box-title">社交账号</h3>
					<div class="box-tools">
						<div class="input-group input-group-sm" style="width: 150px;">
							<input type="text" name="table_search" class="layui-input pull-right" placeholder="Search">
							<div class="input-group-btn">
								<button type="submit" class="btn btn-default" onclick="alert('未开发')">
									<i class="fa fa-search"></i>
								</button>
							</div>
						</div>
					</div>
				</div>
				<!-- /.box-header -->
				<div class="box-body table-responsive no-padding">
					<table class="table table-hover">
						<tr>
							<th>社交账号</th>
							<th>id</th>
							<th>操作</th>
						</tr>
						<tr v-for='item in items'>
							<td>
								<p v-if="item.providerid=='baidu'">百度</p>
								<p v-if="item.providerid=='ali'">支付宝</p>
								<p v-if="item.providerid=='qq'">腾讯</p>
								<p v-if="item.providerid=='sina'">新浪</p>
								<p v-if="item.providerid=='weixin'">微信</p>
							</td>
							<td>{{item.provideruserid}}</td>
							<td>
								<button type="button" class="layui-btn layui-btn-danger " @click="delsocial(item.providerid,item.provideruserid)">删除</button>
							</td>
						</tr>
					</table>
				</div>
				<!-- /.box-body -->
			</div>
			<!-- /.box -->
		</div>
		<div id="passwordLayer" style="display: none; width: 500px;">
			<form class="layui-form-layui-form-pane">
				<div class="layui-form-item">
					<div class="layui-form-label ">原密码</div>
					<div class="col-sm-7 col-xs-6">
						<input type="password" class="layui-input" v-model="password" placeholder="原密码" />
					</div>
					<!-- Left side column. contains the sidebar -->
				</div>
				<div class="layui-form-item">
					<div class="layui-form-label ">新密码</div>
					<div class="col-sm-7 col-xs-5">
						<input type="password" class="layui-input" v-model="newPassword" placeholder="新密码" />
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-form-label ">再次确认</div>
					<div class="col-sm-7 col-xs-5">
						<input type="password" class="layui-input" v-model="newPassword2" placeholder="新密码" />
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-form-label ">验证码</div>
					<img id="vrifyCode_modifypwd" alt="验证码" onclick="this.src='/defaultKaptcha?d='+new Date()*1" src="/defaultKaptcha" />
					<input type="text" placeholder="请输入验证码" required="required" id="vrifyCode" name="vrifyCode" class="layui-input input-sm" style="width: 30%; display: inline;">
				</div>
			</form>
		</div>
	</div>
	<font color="red">绑定当前版本不支持 即时绑定。请退出后再绑定</font>
	<script>
        var vm = new Vue({
            el : '#rrapp',
            data : {
            	items:null,
                password : "",
                newPassword2 : "",
                newPassword : ""
            },
            methods : {
                boundinfo : function() {
                    $.ajax({
                        type : "GET",
                        url : rootPath + "/thirdoartlogin_do/boundinfo.do",
                        dataType : "json",
                        success : function(data) {
                            vm.items = data.list;
                            
                        }
                    });
                },
                toupdatepwd : function() {
                    $("#passwordLayer").css("display", 'block');
                },
                updatePassword : function() {
                    layui.use('layer', function(){ 
                        var  layer = layui.layer
                        layer.open({
                            type : 1,
                            skin : 'layui-layer-molv',
                            title : "修改密码",
                            area : [
                                    '600px', '600px'],
                            shadeClose : false,
                            content : jQuery("#passwordLayer"),
                            btn : [
                                    '修改', '取消'],
                            btn1 : function(index) {
                                if (vm.newPassword != vm.newPassword2) {
                                    alert("两次密码不一致");
                                    return false;
                                }
                                var data = "password=" + vm.password + "&newPassword=" + vm.newPassword;
                                $.ajax({
                                    type : "POST",
                                    url : "/common/login_do/modifypwd.do",
                                    data : {
                                        password : vm.password,
                                        newPassword : vm.newPassword,
                                        vrifyCode : $("#vrifyCode").val()
                                    },
                                    dataType : "json",
                                    success : function(data) {
                                        alert(data.msg);
                                        $("#vrifyCode_modifypwd").attr("src", '/defaultKaptcha?d=' + new Date() * 1);
                                    }
                                });
                            }
                        });
                    });
                   
                },
                delsocial : function(pro,provideruserid) {
                    confirm('确定要删除关联？', function() {
                        $.ajax({
                            type : "POST",
                            url : rootPath + "/thirdoartlogin_do/delsocialbind.do",
                            dataType : "json",
                            data : {
                                providerid : pro,
                                provideruserid,provideruserid
                            },
                            success : function(data) {
                                layui.use('layer', function(){ 
                                  var  layer = layui.layer
                                    layer.closeAll(); 
                                });
                                alert(data.msg);
                                vm.boundinfo();
                                return false;
                            }
                        });
                        
                    });
                   
                },
                connected : function(pro) {
                    location.href = rootPath + "/connect/" + pro + "Connected";
                }
            }
        });
        vm.boundinfo();
    </script>
</body>
</html>
<!-- /.content -->
<!-- /.content-wrapper -->